﻿@using Utils;
@model WebUI.Models.JobViewModel
@{
    if (!Model.IsValidPage)
    {
        ViewBag.Title = "Job doesn't exist - Juicy Basket";
    }
    else{
        ViewBag.Title = Model.Job.Title + " at " + Model.Co.Name + " - Juicy Basket";
    }
    Layout = "~/Views/Shared/_Layout.cshtml";
}


@if (!Model.IsValidPage)
{ 
    <div class="null-message">
	    <h2>The job you are looking for doesn't exist. Please check other <a href="/jobs">job opportunities</a></h2>
    </div>
}
else if (Model.Job.Status != 1)
{
    <div class="null-message">
	    <h2>The job you are looking for is either no longer active or unpublished. Please check other <a href="/jobs">job opportunities</a></h2>
    </div>
}
else
{
<input type="hidden" id="jobID" value="@Model.Job.JobID"/>
<div class="mainSection">
    <div class="clear"></div>
    <div class="mainCol jobpreview">
        <div class="jobprofile">
            <div class="left">
                <a href="@Model.Co.CoUrl" target="_blank"><img src="@Url.StaticFile(Model.AvatarUrl)" alt="logo" class="avatar80"/></a>
            </div>
            <div class="right">
                <h1 class="title">
                    <a href="/jobs/@Model.Job.JobID/@CommonUtilities.GetTitleInUrl(Model.Job.Title)">@Model.Job.Title.ToUpperAllFirstLetter()</a>
                </h1>
                <div class="company">
                    <a href="@Model.Co.CoUrl" target="_blank">@Model.Co.Name</a> -
                    <em>@Model.Job.Location
                    @if (Model.Job.RelocationOffered)
                    { 
                        @:- Relocation assistance offered
                    }
                    @if (Model.Job.AllowTelecommute)
                    { 
                        @:- Telecommute opportunity
                    }
                    </em>
                </div>
                <div class="smallspacer"></div>
                <ol class="tags">
                    @foreach (var keyword in Model.Job.JobKeywordList)
                    { 
                        <li><a href="/jobs/tag/@keyword">@keyword</a></li>
                    }
                </ol>
            </div>
        </div>

        <div class="spacer"></div>
        <div class="richhtml">
            @Html.Raw(Model.Job.Description)
        </div>
        @if (!string.IsNullOrEmpty(Model.Job.Perk))
        {
            <div class="jobtextblock">
                <div class="title perktitle">Job Perks</div>
                @Model.Job.Perk
            </div>
        }
        @if (!string.IsNullOrEmpty(Model.Co.Description))
        {
            <div class="jobtextblock richhtml">
                <div class="title">Company Description</div>
                @Html.Raw(Model.Co.Description)
            </div>
        }
        <div class="jobtextblock">
            <div class="title">Additional Information</div>
            <div class="job-ai">
                <div class="left">Posted:</div>
                <div class="right">@Model.Job.CreateDate.ToDateTimeString()</div>
            </div>
            <div class="clear"></div>
            <div class="job-ai">
                <div class="left">Type:</div>
                <div class="right">@Model.Job.JobType</div>
            </div>
            <div class="clear"></div>
            <div class="job-ai">
                <div class="left">Experience:</div>
                <div class="right">@Model.Job.JobExp</div>
            </div>
            <div class="clear"></div>
            @if (!string.IsNullOrEmpty(Model.Job.Compensation))
            {
            <div class="job-ai">
                <div class="left">Compensation:</div>
                <div class="right">@Model.Job.Compensation</div>
            </div>
            }
        </div>

        <div class="jobtextblock">
            <div class="title">How to apply</div>
            @if (Model.Job.ApplyViaEmail)
            {
                <div>
                    Contact <a href="mailto:@Model.Job.ApplyEmail">@Model.Job.ApplyEmail</a>. 
                </div>
            
            }
            else
            { 
                <div>Apply via <a href="@Model.Job.ApplyUrl">@Model.Job.ApplyUrl</a></div>
            }
            <div class="richhtml">
                <ul>
                    @if (Model.Job.OnlinePortfolioRequired)
                    { 
                        <li>Online portfolio required</li>
                    }
                    @if (Model.Job.OnlinePDFResumeRequired)
                    { 
                        <li>Online text/pdf resume required</li>
                    }
                </ul>
            </div>
        </div>
    </div>
    <div class="sideCol">
        <div class="jobshare">
            <a class="email" href="mailto:@Model.ShareToFriendUrl">mail to a friend</a>
            @if (Model.Identity.IsLoggedIn)
            {
                if (Model.IsJobSaved)
                {
                    <a class="saved" href="@Url.Action("unsave", "job", new { JobID = Model.Job.JobID })" title="This job listing is now in your saved job list. Click if you'd like to remove.">remove from saved jobs</a>
                    <a class="save" href="@Url.Action("save", "job", new { JobID = Model.Job.JobID })" title="Click to save this job." style="display:none;">save this job</a>
                }
                else
                {
                    <a class="saved" href="@Url.Action("unsave", "job", new { JobID = Model.Job.JobID })" title="This job listing is now in your saved job list. Click if you'd like to remove." style="display:none;">remove from saved jobs</a>
                    <a class="save" href="@Url.Action("save", "job", new { JobID = Model.Job.JobID })" title="Click to save this job.">save this job</a>
                }
            }
            else
            { 
                <a class="save gotosignin" href="/signin" title="Click to save this job.">save this job</a>
            }
            <a class="twitter" href="@Model.ShareToTwitterUrl">tweet this job</a>
            <a class="facebook" href="@Model.ShareToFacebookUrl">share this job on facebook</a>
        </div>
    </div>
    <div class="clear"></div>
    <div class="largespacer"></div>
</div>
}

@section FooterContent
{
    <script type="text/javascript">
        $(function () {
            setShareButtons();

            $(".save:not('.gotosignin')").live("click", function () {
                $.ajax({
                    type: "POST",
                    url: $(this).attr("href"),
                    data: "",
                    success: function (data) {
                        if (data.Success == 1) {
                            $(".save").hide();
                            $(".saved").show();
                        }
                        return false;
                    }
                })
                return false;
            })

            $(".saved").live("click", function () {
                $.ajax({
                    type: "POST",
                    url: $(this).attr("href"),
                    data: "",
                    success: function (data) {
                        if (data.Success == 1) {
                            $(".saved").hide();
                            $(".save").show();
                        }
                        return false;
                    }
                })
                return false;
            })
        })
        
    </script>
}

